//
//  RegistrationColorCellViewModel.swift
//  PorscheRegistration
//
//  Created by Jinzhu Liu on 2023/11/16.
//

import Foundation
import Combine

protocol RegistrationColorCellViewModelInputType {
    func setTextValue(text: String)
}

protocol RegistrationColorCellViewModelOutputType: RegistrationTitleCellViewModelOutputType,
                                                   RegistrationTextFieldCellViewModelOutputType {
    
}

protocol RegistrationColorCellViewModelType: RegistrationCellViewModelType {
    var input: RegistrationColorCellViewModelInputType { get }
    var output: RegistrationColorCellViewModelOutputType { get }
}

class RegistrationColorCellViewModel: ObservableObject,
                                      RegistrationColorCellViewModelType,
                                      RegistrationColorCellViewModelInputType {
    
    var input: RegistrationColorCellViewModelInputType { self }
    var output: RegistrationColorCellViewModelOutputType { self }
    
    var title: String = "Custom Avatar Color"
    var textFieldEnable: Bool = false
    
    @Published var textValue: String = ""
    
    func setTextValue(text: String) {
        textValue = text
    }
}

extension RegistrationColorCellViewModel: RegistrationColorCellViewModelOutputType {
    var textValuePublisher: AnyPublisher<String, Never> {
        $textValue.eraseToAnyPublisher()
    }
}
